package models

import "gorm.io/gorm"

type Home struct {
	gorm.Model
	Title   string  `gorm:"type:varchar(20);not null;comment:标题"`
	Address string  `gorm:"type:varchar(30);not null;comment:地址"`
	Num     int     `gorm:"type:int(11);not null;comment:面积"`
	Price   float64 `gorm:"type:decimal(10,2);not null;comment:价格"`
}

func (h *Home) Create() error {
	return DB.Debug().Create(&h).Error
}
func (h *Home) Findlist() (homeList []*Home, err error) {
	err = DB.Debug().Find(&homeList).Error
	return
}
func (h *Home) HomeShow() error {
	return DB.Debug().Where("id = ?", h.ID).Limit(1).Find(&h).Error
}
